package otherSamples;

import java.net.DatagramPacket;
import java.net.InetAddress;
import java.net.UnknownHostException;

public class DatagramExample {
	public static void main(String[] args) {
		String s = "Essayons.";
		byte[] data = s.getBytes( );
		try {
			InetAddress ia = InetAddress.getByName("www.liafa.jussieu.fr");
			int port =7;
			DatagramPacket dp = new DatagramPacket(data, data.length, ia,port);
			System.out.println("Un packet pour " + dp.getAddress( ) + " port " + dp.getPort( ));
			System.out.println("il y a " + dp.getLength( ) + " bytes dans le packet");
			System.out.println(new String(dp.getData( ), dp.getOffset( ), dp.getLength( )));
		}
		catch (UnknownHostException e) {
			System.err.println(e);
		}
	}
}
